package com.shrct.businessprocess.product.impl;

import edu.fudan.langlab.domain.organization.RoleContributor;
import edu.fudan.langlab.domain.organization.RoleManager;
import edu.fudan.langlab.domain.organization.SystemRoleManager;
import edu.fudan.langlab.domain.security.AppRole;
import edu.fudan.mylang.pf.BaseService;
import java.util.Collection;
import java.util.List;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("com.shrct.businessprocess.product.ShrclRoleManager")
public class ShrclRoleManagerImpl extends BaseService implements RoleManager {
  @Autowired
  private SystemRoleManager systemRoleManager;
  
  public Collection<AppRole> getAllRoles() {
    Collection<RoleContributor> _roleContributors = this.systemRoleManager.getRoleContributors();
    final Function1<RoleContributor,AppRole> _function = new Function1<RoleContributor,AppRole>() {
        public AppRole apply(final RoleContributor roleContributor) {
          AppRole _appRole = new AppRole();
          final Procedure1<AppRole> _function = new Procedure1<AppRole>() {
              public void apply(final AppRole it) {
                String _roleId = roleContributor.getRoleId();
                it.setRoleId(_roleId);
                String _description = roleContributor.getDescription();
                it.setName(_description);
              }
            };
          AppRole _doubleArrow = ObjectExtensions.<AppRole>operator_doubleArrow(_appRole, _function);
          return _doubleArrow;
        }
      };
    Iterable<AppRole> _map = IterableExtensions.<RoleContributor, AppRole>map(_roleContributors, _function);
    List<AppRole> _list = IterableExtensions.<AppRole>toList(_map);
    return _list;
  }
}
